<script type="text/javascript" charset="utf-8" src="js/kind/kindeditor.js"></script>
<script type="text/javascript">
KE.init({
	id : 'content1',
	width : '100%',
	height : '500px',
	resizeMode : 1,
	filterMode : true,
	skinsPath : '{conf site_url}/templates/default/js/kind/skins/',
    pluginsPath : '{conf site_url}/templates/default/js/kind/plugins/',
    emoticonsPath : '{conf site_url}/templates/default/images/',
	items : [
            'emoticons', 'justifycenter','insertorderedlist','title','textcolor','bold','image'
	]
});
setTimeout("KE.create('content1');",100);
</script>
<div class="event_pbox">
<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank" style="display:none;z-index:0;"></iframe>
  <form name="FORM" id="FORM" method="post" action="index.php?mod=article&code=pevent" enctype="multipart/form-data" target="uploadframe">
  
    <table><tr><td>
      <table id="step1" align="left">
        <tr>
          <td width="100"><span>*</span>标题：</td>
          <td><input type="text"  size="30" maxlength="50" id="name" name="name" value="{$title}" class="inputs">
          <sup id="name_tips" style="display:none; color:#FF0000;"></sup></td>
        </tr>
        <tr>
          <td><span>*</span>类别：</td>
          <td>{$article_type}</td>
        </tr>
        <!--{if $top == 'top'}-->
        <tr>
        <td align="center">&nbsp;</td>
		<td><input type="button" id="next2" name="next2" value="下一步" onclick="set_step(2,this.form);return false;" class="btnText"></td>
		</tr>
        <!--{/if}-->
      </table>
	</td></tr></table>
	
	<table><tr><td>
      <table id="step2" align="left">
        <tr>
          <td><span>*</span>内容:<br>
		  <textarea name="content1" id="content1">{$content}</textarea>
		  <sup id="content1_tips" style="display:none; color:#FF0000;"></sup>
		  </td></tr>
        <tr>
          <td><span>*</span>上传文章海报：
            <input type="file" id="pic" name="pic" onchange="onloadPic();">
            <sup id="message" style="display:none; color:#FF0000;"></sup>
            <sup id='uploading' style="display:none"><img src="images/loading.gif">图片正在上传中、请稍等...</sup>
            <sup id="hid_pic_tips" style="display:none; color:#FF0000;"></sup>
            <input type="hidden" id="hid_pic" name="hid_pic" value="{$image}">
          </td>
        </tr>
        
        <tr id="img" style="display:none">
          <td>
            <img id="showimg" name="showimg" src="{$image}" height="90" width="100"></img>
          </td>
        </tr>
        <!--{if $top == 'top'}-->
        <tr>
          <td align="center">
          <input type="button" id="back1" name="back1" value="上一步" onclick="set_step(1,this.form);return false;" class="canlText" style="display:inline">
          <input type="button" id="next3" name="next3" value="下一步" onclick="set_step(3,this.form);return false;" class="btnText" style="display:inline">
          </td>
        </tr>
        <!--{/if}-->
      </table>
	</td></tr></table>
	
	<table><tr><td>
      <table id="step3" align="left">
        <!--{if $info}-->
        <tr>
          <td>勾选报名时需要用户填写的内容：</td>
        </tr>
        <tr>
          <td>
            <!--{loop $info $key1 $val1}-->
            <label><input type="checkbox" id="{$val1['fieldid']}" name="info[{$val1['fieldid']}]" value={$key1} {$val1['checked']}>$val1['title']</label>
            <!--{/loop}-->
          </td>
        </tr>
        <!--{/if}-->
        <tr>
          <td align="center">
          <!--{if $top == 'top'}-->
            <input type="button" id="back2" name="back2" value="上一步" onclick="set_step(2,this.form);return false;" class="canlText">
          <!--{/if}-->
            <input type="button" name="SUBMIT" value="发布" onclick="formSubmit();" class="btnText">
            <input type="hidden" id="top" name="top" value="{$top}">
            <input type="hidden" id="act" name="act" value="{$act}">
            <input type="hidden" id="id" name="id" value="{$id}">
          </td>
        </tr>
      </table>
	</td></tr></table>
    </form>
    <div id="publish_share"></div>
<script type="text/javascript">
function set_step(num,form){
	if(num == 1){
		$('#step1').show();
		$('#step2').hide();
		$('#step3').hide();
	}else if(num == 2){
		var check = checkEventStep1();
		if(check == false){return false;}
		$('#step1').hide();
		$('#step2').show();
		$('#step3').hide();
	}else if(num == 3){
		var check = checkEventStep2();
		if(check == false){return false;}
		
		$('#step1').hide();
		$('#step2').hide();
		$('#step3').show();
	}
}
<!--{if $top == 'top'}-->
$(document).ready(function() {
set_step(1);
})
<!--{/if}-->
function checkEventStep1(){
	var name = $("#name").val();
	if(strlen(name) < 2){
		$("#name_tips").html("标题必须有哦");
		$("#name_tips").show();
		$("#name").focus();
		return false;
	}else{$("#name_tips").hide();}

}

function checkEventStep2(){
	var content = $("#content1").val();
	if(strlen(content) < 2){
		$("#content1_tips").html("内容必须有哦");
		$("#content1_tips").show();
		$("#content1").focus();
		return false;
	}else{
		$("#content1_tips").hide();
	}
	
	return true;
}
function onloadPic(){
	var fn = $('#pic').val();
	if (!/.(gif|jpg|png|jpeg)$/i.test(fn)) {
		alert("请上传jpg、jpeg、gif、png格式的图片。");
		return false;
	}
	var top = $('#top').val();
	if(top == 'top'){
		document.getElementById('back1').style.display = 'none';
		document.getElementById('next3').style.display = 'none';
	}
	document.getElementById('uploading').style.display = 'block';
	document.FORM.target="uploadframe";
	document.FORM.action="ajax.php?mod=article&code=onloadPic";
	$('#FORM').submit();
  }

function formSubmit(){
	if(false === checkEventStep1()){
		return false;
	}
	if(false === checkEventStep2()){
		return false;
	}
	document.FORM.target="";
	var top = document.getElementById('top').value;
	var post_data = $('#FORM').serialize();
	$.post(
		"ajax.php?mod=article&code=create&item="+__APPITEM__+"&item_id="+__APPITEM_ID__, 
		post_data, 
		function(r){
			if(!is_json(r)){
				var handle_key = 'publish_share';
				showDialog(handle_key, 'local', '分享', {html:r}, 500);
				
				$('#topic_simple_close_btn').click(
					function() {
						location.href = "index.php?mod=article&code=detail&id="+$("#topic_simple_item_id").val();
					}
				);
				$('#topic_simple_share_btn').click(
					function () {
						var response = function() {
							location.href = "index.php?mod=article&code=detail&id="+$("#topic_simple_item_id").val();
						}
						publishSimpleTopic($('#topic_simple_content').val(), 'article', $("#topic_simple_item_id").val(), {response:response})
					}
				);
			}else{
				var json = eval('('+r.toString()+')');
				if (json.done) {
					if(top){
					    MessageBox('notice',json.msg);
						if($('#i_already').length > 0){
							$('#i_already').val(json.retval.content);
						}else{
							$('#i_alreadyajax').val(json.retval.content);
						}
						//$('#i_already').val(json.retval.content);
						//$('#mapp_item').val(json.retval.from);
						//$('#mapp_item_id').val(json.retval.id);
						$(".menu_hdb").hide();
					}else{
						MessageBox('notice',json.msg);
						location.href = "index.php?mod=article&code=detail&id="+json.retval.id;
					}
				} else {
					if(json.msg.indexOf('发布成功')>0){
						show_message_2(json.msg);
						if(!top){
							location.href = "index.php?mod=article&code=myarticle";
						}else{
							$(".menu_hdb").hide();
						}
					}
					MessageBox('warning', json.msg);
				}
			}
		}
	);
}

function chooseuser(t){
  if(t == 'all'){
	document.getElementById("user").style.display = "none";
  }else if('qua'){
	document.getElementById("user").style.display = "block";
  }
}
<!--{if $qua}-->
$(document).ready(function() {
chooseuser('qua');
})
<!--{/if}-->
	
function choosemoney(t){
  if(t == 'money'){
	document.getElementById("money").readOnly = false;
  }else if(t == 'free'){
	document.getElementById("money").readOnly = "readonly";
  }
}
<!--{if $money}-->
$(document).ready(function() {
choosemoney('money');
})
<!--{/if}-->

function choosefans(){
  var fans = document.getElementById("fans").checked;
  if(fans){
    document.getElementById("fans_num").readOnly = false;
  }else{
	document.getElementById("fans_num").readOnly = "readonly";
  }
}
$(document).ready(function() {
choosefans();
})

<!--{if $image}-->
document.getElementById("img").style.display = 'block';
<!--{/if}-->
</script>
<script src="js/date/WdatePicker.js" type="text/javascript"></script>
</div>